import request from '@/utils/request'

// 查询报工单列表
export function listRwork(query) {
  return request({
    url: '/sl/rwork/list',
    method: 'get',
    params: query
  })
}

// 查询所有未提交的报工项列表
export function listNoSubmitRwork(query) {
  return request({
    url: '/sl/rwork/notlist',
    method: 'get',
    params: query
  })
}

// 查询历史报工单列表
export function listHRwork(query) {
  return request({
    url: '/sl/rwork/hlist',
    method: 'get',
    params: query
  })
}

// 查询报工单详细
export function getRwork(rworkId) {
  return request({
    url: '/sl/rwork/' + rworkId,
    method: 'get'
  })
}

// 新增报工单
export function addRwork(data) {
  return request({
    url: '/sl/rwork',
    method: 'post',
    data: data
  })
}

// 修改报工单
export function updateRwork(data) {
  return request({
    url: '/sl/rwork',
    method: 'put',
    data: data
  })
}

// 非批量鼓号修改报工单
export function updateSingleRwork(data) {
  return request({
    url: '/sl/rwork/edit',
    method: 'put',
    data: data
  })
}

// 删除报工单
export function delRwork(rworkId) {
  return request({
    url: '/sl/rwork/' + rworkId,
    method: 'delete'
  })
}

//查询报工人信息
export function rworkUserBase(userName) {
  return request({
    url: '/sl/rwork/user/' + userName,
    method: 'get'
  })
}

// 新增打开报工单页面是获取页面上的选项内容
export function getRworkOptions(data) {
  return request({
    url: '/sl/rwork/option',
    method: 'get',
    params: data
  })
}

//最后一次报工项的操作人
export function getLastmember() {
  return request({
    url: '/sl/rwork/lastmember',
    method: 'get'
  })
}

//最后一次报工项的操作人
export function getOftenMember(userName) {
  return request({
    url: '/sl/rwork/often/'+userName,
    method: 'get'
  })
}


//防止选人重复添加
export function isUniqueUser(arr,obj){
  for(var i = 0; i < arr.length; i++){
    if(arr[i].rmemberUser===obj.rmemberUser){
        return false;
    }
  }
  return true;
}

// 更新报工单开始结束时间
export function updateRworkDateTime(data) {
  return request({
    url: '/sl/rwork/upd',
    method: 'put',
    data: data
  })
}
//提交整张报工单
export function submitDateRworks(data) {
  return request({
    url: '/sl/rwork/daterws',
    method: 'post',
    data: data
  })
}

// 根据报工单查询报工项
export function listRworkByrfworkId(rfworkId) {
  return request({
    url: '/sl/rwork/rfw/' + rfworkId,
    method: 'get'
  })
}

//查询产量
export function getProList(data) {
  return request({
    url: '/sl/rwork/production/',
    method: 'post',
    data: data
  })
}

